home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
trueSpace 7.6
/
tS761B8Std.exe
/
{app}
/
Scripts
/
D3D
/
RsD3DShadowMapRT2.fx
< prev
next >
Wrap
Text File
|
2008-06-10
|
4KB
|
139 lines
//----------------------------------------------------------------------
//Shadow map rendering
//
//Author - Michal Valient
//Copyright (C) 2004-2008 Caligari corporation
//
//----------------------------------------------------------------------
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//Keep in sync with shadow portion in RsD3DMaterialFromME2_Template.fx
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
uniform float4x4 mToClip;
uniform float fBias;
struct VS_MATSHADOW_IN {
float4 vPosition : POSITION; //position in object space
};
typedef struct {
float4 vPosition : POSITION;
float4 vPosition2: TEXCOORD0;
} VS_MATSHADOW_OUT;
VS_MATSHADOW_OUT VS_CMaterialShadowBuffer(in VS_MATSHADOW_IN input)
{
VS_MATSHADOW_OUT output;
output.vPosition = mul(input.vPosition, mToClip); //vertex clip position
output.vPosition2 = output.vPosition;
return output;
}
float4 VS_CMaterialShadowBufferHardware(in VS_MATSHADOW_IN input) : POSITION
{
float4 ret_val = mul(input.vPosition, mToClip); //vertex clip position
return ret_val;
}
float4 PS_CMaterialShadowBuffer(in VS_MATSHADOW_OUT input) : COLOR
{
float4 vRet;
float fVal = input.vPosition2.z / input.vPosition2.w + fBias;
vRet.x = fVal * 255.0f;
vRet.y = (vRet.x - floor(vRet.x)) * 255.0f;
vRet.z = (vRet.y - floor(vRet.y)) * 255.0f;
vRet.w = (vRet.z - floor(vRet.z)) * 255.0f;
vRet = floor(vRet) / 255.0f;
// vRet.x = floor(vRet.x) / 255.0f;
// vRet.y = floor(vRet.y) / 255.0f;
// vRet.z = floor(vRet.z) / 255.0f;
// vRet.w = floor(vRet.w) / 255.0f;
// vRet.x = input.vPosition2.z / input.vPosition2.w + fBias;
// vRet.y = frac(vRet.x * 256.0f);
// vRet.z = frac(vRet.y * 256.0f);
// vRet.w = frac(vRet.z * 256.0f);
return vRet;
}
float4 PS_CMaterialShadowBufferHardware() : COLOR
{
return 0;
}
float4 PS_CMaterialShadowBufferHQ(in VS_MATSHADOW_OUT input) : COLOR
{
return input.vPosition2.z / input.vPosition2.w + fBias;
}
vertexshader VS_CMaterialShadowBuffer20 = compile vs_2_0 VS_CMaterialShadowBuffer();
vertexshader VS_CMaterialShadowBufferHardware11 = compile vs_1_1 VS_CMaterialShadowBufferHardware();
pixelshader PS_CMaterialShadowBuffer20 = compile ps_2_0 PS_CMaterialShadowBuffer();
pixelshader PS_CMaterialShadowBuffer20HQ = compile ps_2_0 PS_CMaterialShadowBufferHQ();
pixelshader PS_CMaterialShadowBufferHardware11 = compile ps_1_1 PS_CMaterialShadowBufferHardware();
technique T_ShadowMapRGBA8
{
pass P0
{
VertexShader = (VS_CMaterialShadowBuffer20);
PixelShader = (PS_CMaterialShadowBuffer20);
AlphaBlendEnable = false;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Cullmode = NONE;
}
}
technique T_ShadowMapMQ
{
pass P0
{
VertexShader = (VS_CMaterialShadowBuffer20);
PixelShader = (PS_CMaterialShadowBuffer20HQ);
AlphaBlendEnable = false;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
Cullmode = NONE;
}
}
technique T_ShadowMapHardware
{
pass P0
{
VertexShader = (VS_CMaterialShadowBufferHardware11);
PixelShader = (PS_CMaterialShadowBufferHardware11);
AlphaBlendEnable = false;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = true;
ColorWriteEnable = 0;
Cullmode = NONE;
}
}